package com.gomoku.botrunning.controller;

import com.alibaba.fastjson2.JSON;
import com.gomoku.botrunning.service.BotMoveSevice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

@RestController
public class BotMoveController {
    @Autowired
    private BotMoveSevice botMoveSevice;

    @PostMapping("/pk/botrunning/")
    public String botrunning(@RequestParam MultiValueMap<String,String>data){
        Integer userId = Integer.valueOf(Objects.requireNonNull(data.getFirst("userId")));
        Integer botId = Integer.valueOf(Objects.requireNonNull(data.getFirst("botId")));
        String input = data.getFirst("input");
        return botMoveSevice.getBotMove(userId,botId,input);
    }
}
